import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter/widgets.dart';

class PositionedDemoPage extends StatefulWidget {
  @override
  State<StatefulWidget> createState() {
    return PositionedDemoPageState();
  }
}

class PositionedDemoPageState extends State<PositionedDemoPage> {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(title: Text('绝对定位例子')),
      body: Container(
        height: MediaQuery.of(context).size.height,
        width: MediaQuery.of(context).size.width,
        margin: EdgeInsets.all(10),
        child: Stack(
          children: <Widget>[
            MaterialButton(
              onPressed: () {},
              color: Colors.blue,
            ),
            Positioned(
              child: MaterialButton(
                onPressed: () {},
                color: Colors.yellow,
              ),
              left: MediaQuery.of(context).size.width / 2,
              top: MediaQuery.of(context).size.height / 2,
            )
          ],
        ),
      ),
    );
  }
}
